The present invention pertains generally to the field of computer systems and more particularly to a system and method for decoding the links of macrocode instructions within pipelined or super pipelined microprocessors.
Processors (including, but not limited to, general and special purpose microprocessors, micro-controllers, and digital signal processors (DSPs)) typically include execution units that execute a sequence of instructions, termed micro-instructions, derived from a computer program. Many computer programs are written in a high level language that is not directly executable by the central processing unit (CPU) of a computer and the instructions of such programs must accordingly be decoded into a form suitable for execution by the CPU. For example, a program may be written in a high level language such as C, C++, or Java, and then compiled into a corresponding sequence of macro-instructions, which are in turn decoded into micro-instructions for eventual execution. Programs can also be written directly of a series of macro-instructions (that is, machine code).
Macro-instructions are commonly stored as contiguous data blocks in a memory resource, such as main memory (ergo, RAM) or in a cache, for retrieval and supplied to a decoder unit within a processor for decoding into micro-instructions. To enable the decoder unit successfully to decode macro-instructions, it will be appreciated that it is necessary to identify instruction boundaries within retrieve data blocks, that constitute the instruction stream, that indicate where one macro-instruction ends and the next begins.
The task of identifying such instruction boundaries by processors having complex instruction set (CISC) architectures, such as the Intel architecture (IA) developed by Intel Corporation of Santa Clara, Calif., is complicated by the use of a variable-length instruction set (e.g., the Intel architecture (IA) instruction set). Specifically, in reduced instruction set computer (RISC) processor architectures and instruction sets, macro-instructions typically had a fixed length, in which case the boundaries between instructions can be determined with relative ease once an initial boundary is identified, as each instruction has a known length. For a variable-length instruction set, once an initial boundary location is identified, the length of each macro-instruction must be ascertained to identify subsequent instruction boundaries. The task of identifying boundaries is further complicated by a variable-length instruction set that, for the purposes of supporting legacy programs, supports multiple data and addressing sizes.
A system and method for decoding the length of a macro instruction is described. In one embodiment, the system comprises an opcode-plus-immediate logic unit to generate a first length value, the first length value comprising a length of an opcode plus a length of intermediate data. A memory-length logic unit generates a second length value, the second length value comprising a potential length of a memory displacement, the opcode-plus-immediate logic unit and memory-length logic unit operating in parallel. In addition, the system comprises a length-summation logic unit to sum the first length value and the second length value if the second length value is present.